#include <iostream>
#include <cstring>
using namespace std;
const int N = 1e5 + 5, M = 2 * N;
int h[N], e[M], ne[M], idx;
void add(int a, int b)
{
    e[idx] = b; ne[idx] = h[a]; h[a] = idx++;
}

bool st[N];
int match[N];
int n1, n2, m;

bool find(int u)
{
    for(int i = h[u]; i != -1; i = ne[i])
    {
        int j = e[i];
        if(st[j]) continue;
        st[j] = true;
        if(match[j])
        {
            if(find(match[j]))
            {
                match[j] = u;
                return true;
            }
        }
        else
        {
            match[j] = u;
            return true;
        }
    }
    return false;
}

int main()
{
    memset(h, -1, sizeof(h));
    cin >> n1 >> n2 >> m;
    while(m--)
    {
        int a, b; cin >> a >> b;
        add(a, b);
    }
    int ans = 0;
    for (int i = 1; i <= n1; ++i)
    {
        memset(st, false, sizeof(st));
        if(find(i)) ans ++;
    }
    cout << ans;
    return 0;
}